package com.xyzh05.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xyzh05.dao.SchoolDao;
import com.xyzh05.model.School;
import com.xyzh05.service.SchoolManager;
import com.xyzh05.util.PageBean;

@Service("schoolManager")
@WebService(serviceName = "SchoolService", endpointInterface = "com.xyzh05.service.SchoolManager")
public class SchoolManagerImpl extends GenericManagerImpl<School, Long> implements SchoolManager {
    SchoolDao schoolDao;

    @Autowired
    public SchoolManagerImpl(SchoolDao schoolDao) {
        super(schoolDao);
        this.schoolDao = schoolDao;
    }

	public PageBean findList(PageBean pageBean, School school) {
		StringBuilder sb = new StringBuilder();
		List list = new ArrayList();
		sb.append(" from School where 1 = 1 ");

		if (pageBean != null) {
			if (pageBean.getSortCriterion() != null) {
				sb.append(" order by ");
				sb.append(pageBean.getSortCriterion() + " ");
				if (pageBean.getSortParamDirection() != null) {
					sb.append(pageBean.getSortParamDirection());
				}
			}
		}
		return schoolDao.getPageByHQL(sb.toString(), pageBean, list.toArray());
	}

	public List<School> querySchoolAutoComplete(String keyword) {
		return schoolDao.querySchoolAutoComplete(keyword);
	}
	
	
}